package net.lmc.realtime.jtp.dws.log.function;

import net.lmc.realtime.jtp.dws.log.bean.PageViewBean;
import org.apache.flink.api.common.functions.ReduceFunction;

public class PageViewReportReductFunction implements ReduceFunction<PageViewBean> {
    @Override
    public PageViewBean reduce(PageViewBean value1, PageViewBean value2) throws Exception {

        //value1 表示新增计算结果  value2 表示窗口中原来每条数据

        //1增量计算
        value1.setPageCount(value1.getPageCount() + value2.getPageCount());
        value1.setPvDuringTime(value1.getPvDuringTime() + value2.getPvDuringTime());
        value1.setUvCount(value1.getUvCount() + value2.getUvCount());
        value1.setSessionCount(value1.getSessionCount() + value2.getSessionCount());

        return value1;
    }
}
